<?php

namespace App\HttpController;

use App\Services\System\Admin\SystemRoleServices;
use App\Services\System\SystemMenusServices;
use EasySwoole\Http\AbstractInterface\Controller;
use const EASYSWOOLE_ROOT;
use function aaa;

class Index extends Controller {

    public function index() {
	
	$a = aaa();
	$a = aaa();
	var_dump($a);
	return;
	
	
	$a = SystemMenusServices::getInstance()->createMenus();
	var_dump($a);
	return;
//	$a = \App\Services\System\Admin\SystemAdminServices::getInstance()->verifyLogin('admin', 3);
	$rouleId = 1;
//	$a = \App\Services\System\Admin\SystemRoleServices::getInstance()->getRoleArray(['status' => 1, 'id' => $rouleId]);
//	$a = \App\Services\System\SystemMenusServices::getInstance()->getMenusList(1,1);
//		$a = \App\Services\System\SystemMenusServices::getInstance()->getMenusUnique($a);
	$a = SystemMenusServices::getInstance()->getMenusTreeList();
 
	var_dump($a);
	return;
//	$header = $this->request()->getMethod();
//
//	var_dump($header);
	$adminInfo['roles'] = [1];
//	$a = \App\Services\System\Admin\SystemRoleServices::getInstance()->verifiAuth($adminInfo,'product/product/get_temp_keys','get');
	$a = SystemRoleServices::getInstance()->getRolesByAuth([1],2);
//	$a = \App\Services\System\SystemMenusServices::getInstance()->getRoleAuths([1,2], 1);
	var_dump($a);
	return;
////    $res = Cache::getInstance()->set('easyswoole', 'easyswoole');
////    var_dump($res);
//    $res = Cache::getInstance()->get('easyswoole');
//    var_dump(2,$res);
//	
//$res = \App\Model\Admin\SystemConfigModel::create()->get(1);
////获取查询数据总数,查询时需要调用`withTotalCount`才可以使用该方法
//
//	var_dump($res->toArray());
//
//
//	echo 123;
	$file = EASYSWOOLE_ROOT . '/vendor/easyswoole/easyswoole/src/Resource/Http/welcome.html';
	if (!is_file($file)) {
	    $file = EASYSWOOLE_ROOT . '/src/Resource/Http/welcome.html';
	}
	$this->response()->write(file_get_contents($file));
    }

    function test() {
	$this->response()->write('this is test');
    }

    protected function actionNotFound(?string $action) {
	$this->response()->withStatus(404);
	$file = EASYSWOOLE_ROOT . '/vendor/easyswoole/easyswoole/src/Resource/Http/404.html';
	if (!is_file($file)) {
	    $file = EASYSWOOLE_ROOT . '/src/Resource/Http/404.html';
	}
	$this->response()->write(file_get_contents($file));
    }

}
